<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | 钉钉审批流程创建及修改请求类 v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : Jie
// | Date : 2018-08-09
// +-------------------------------------------------------------------------------

namespace ding\request;


class SmartworkBpmsProcessinstanceCreateRequest extends DingApiRequest {

    /**
     * 审批流的唯一码
     * @var string
     */
    private $process_code;
    /**
     * 审批实例发起人的userid
     * @var string
     */
    private $originator_user_id;
    /**
     * 发起人所在的部门
     * @var int
     */
    private $dept_id;
    /**
     * 审批人userid列表，最大20个
     * @var array
     */
    private $approvers;
    /**
     * 抄送人userid列表
     * @var array
     */
    private $cc_list;
    /**
     * 抄送时间节点，可取的值见：ProcessInstanceCcPositionEnum
     * @var string
     */
    private $cc_position;
    /**
     * 审批流表单参数，最大20个
     * @var array
     */
    private $form_component_values;

    /**
     * SmartworkBpmsProcessinstanceCreateRequest constructor.
     * @param string $process_code
     * @param string $originator_user_id
     * @param int $dept_id
     * @param $approvers
     */
    public function __construct($process_code, $originator_user_id, $dept_id, $approvers) {
        $this->process_code = $process_code;
        $this->originator_user_id = $originator_user_id;
        $this->dept_id = $dept_id;
        if(is_array($approvers)) {
            $approvers = join(",", $approvers);
        }
        $this->approvers = $approvers;
    }

    /**
     * 添加审批流表单参数
     *
     * @param string $name
     * @param string $value
     * @param string $extValue
     * @return $this
     */
    public function addFormComponentValue($name, $value, $extValue = null) {
        if(!is_array($this->form_component_values)) {
            $this->form_component_values = [];
        }

        $item = [
            'name' => $name,
            'value' => $value
        ];
        if($extValue != null) {
            $item['ext_value'] = $extValue;
        }
        $this->form_component_values[] = $item;
        return $this;
    }

    /**
     * @return string
     */
    public function getProcessCode() {
        return $this->process_code;
    }

    /**
     * @param string $process_code
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setProcessCode($process_code) {
        $this->process_code = $process_code;
        return $this;
    }

    /**
     * @return string
     */
    public function getOriginatorUserId() {
        return $this->originator_user_id;
    }

    /**
     * @param string $originator_user_id
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setOriginatorUserId($originator_user_id) {
        $this->originator_user_id = $originator_user_id;
        return $this;
    }

    /**
     * @return int
     */
    public function getDeptId() {
        return $this->dept_id;
    }

    /**
     * @param int $dept_id
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setDeptId($dept_id) {
        $this->dept_id = $dept_id;
        return $this;
    }

    /**
     * @return array
     */
    public function getApprovers() {
        return $this->approvers;
    }

    /**
     * @param array $approvers
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setApprovers($approvers) {
        $this->approvers = $approvers;
        return $this;
    }

    /**
     * @return array
     */
    public function getCcList() {
        return $this->cc_list;
    }

    /**
     * @param array $cc_list
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setCcList($cc_list) {
        $this->cc_list = $cc_list;
        return $this;
    }

    /**
     * @return string
     */
    public function getCcPosition() {
        return $this->cc_position;
    }

    /**
     * @param string $cc_position
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setCcPosition($cc_position) {
        $this->cc_position = $cc_position;
        return $this;
    }

    /**
     * @return array
     */
    public function getFormComponentValues() {
        return $this->form_component_values;
    }

    /**
     * @param array $form_component_values
     * @return SmartworkBpmsProcessinstanceCreateRequest
     */
    public function setFormComponentValues($form_component_values) {
        $this->form_component_values = $form_component_values;
        return $this;
    }

}